Skip to content

refactor(math): use canonical integer conversions - #807

Merged
morluto merged 1 commit into
mainfrom
agent/fix-canonical-integer-conversion
Aug 8, 2026
Merged

refactor(math): use canonical integer conversions#807
morluto merged 1 commit into
mainfrom
agent/fix-canonical-integer-conversion

Conversation

@morluto

@morluto morluto commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Fixes #756.

Replace direct Python decimal conversions at unbounded canonical-integer boundaries with the canonical parser and formatter. This covers contracts, arithmetic, combinatorics, matrix-lattice, polynomial, projective geometry, sequences, plugins, and shrinking.

Regression coverage exercises values beyond CPython's 4,300-digit conversion guard.

Validation:

  • focused arithmetic and contract-boundary tests — 6 + 3 passed
  • affected domain suite — 29 passed
  • matrix-lattice domain suite — 13 passed
  • make lint-full — passed

@morluto
morluto marked this pull request as ready for review August 8, 2026 04:33
@cursor

cursor Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@morluto
morluto merged commit a5f141d into main Aug 8, 2026
39 checks passed
@morluto
morluto deleted the agent/fix-canonical-integer-conversion branch August 8, 2026 04:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b1cfcad10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@model_validator(mode="after")
def require_nonnegative_parts(self) -> Self:
if any(int(v) < 0 for v in self.values):
if any(parse_canonical_integer(value) < 0 for value in self.values):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound multinomial parts before accepting large values

For a multinomial request containing the newly tested 5,001-digit value, this validator now succeeds, but its only consumer passes the parsed value to math.factorial in domains/combinatorics/operations.py:61-62; CPython immediately raises OverflowError once an argument exceeds sys.maxsize. Thus a request accepted by the capability contract still ends in an execution error. Add an explicit supported-magnitude/resource bound here rather than treating every canonical integer as computable.

AGENTS.md reference: AGENTS.md:L16-L17

Useful? React with 👍 / 👎.


def _values(request: IntegerSequenceRequest) -> list[int]:
return [int(value) for value in request.values]
return [parse_canonical_integer(value) for value in request.values]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bound sequence digits before parsing every operand

IntegerSequenceRequest limits only the item count, so this change makes previously guarded oversized operands reachable by every sequence operation. For example, 256 canonical powers of ten with 32,768 digits each fit within the default 10 MiB input limit, but prefix_products retains and formats 256 growing products totaling over one billion decimal digits, allowing one valid request to exhaust server CPU and memory. Enforce a total input/output digit budget before converting the sequence.

AGENTS.md reference: AGENTS.md:L16-L17

Useful? React with 👍 / 👎.

@morluto morluto changed the title Use canonical integer conversions refactor(math): use canonical integer conversions Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: int() and str() on CanonicalInteger strings crash on valid inputs/results above 4300 digits

1 participant